import request from '@/utils/request.ts'
import type { ResponseData } from '@/api/type.ts'
import type {
  TrademarkListData,
  Trademark,
} from '@/api/product/trademark/type.ts'

enum API {
  TRADEMARK_URL = '/admin/product/baseTrademark',
  TRADEMARK_ALL_URL = '/admin/product/baseTrademark/getTrademarkList',
  TRADEMARK_ADD_URL = '/admin/product/baseTrademark/save',
  TRADEMARK_UPDATE_URL = '/admin/product/baseTrademark/update',
  TRADEMARK_DELETE_URL = '/admin/product/baseTrademark/remove',
}

export const reqTrademarkList = (page: number, limit: number) => {
  return request.get<any, ResponseData<TrademarkListData>>(
    `${API.TRADEMARK_URL}/${page}/${limit}`,
  )
}

export const reqAddOrUpdateTrademark = (data: Trademark) => {
  if (data.id) {
    return request.put<any, ResponseData<any>>(API.TRADEMARK_UPDATE_URL, data)
  } else {
    return request.post<any, ResponseData<any>>(API.TRADEMARK_ADD_URL, data)
  }
}

export const reqDeleteTrademark = (id: number) => {
  return request.delete<any, ResponseData<any>>(
    `${API.TRADEMARK_DELETE_URL}/${id}`,
  )
}

export const reqAllTrademarkList = () => {
  return request.get<any, ResponseData<Trademark[]>>(API.TRADEMARK_ALL_URL)
}
